/*
* pps_bom
*/
package com.pitop.project.service;

import com.pitop.core.entity.Page;
import com.pitop.core.exceptions.BaseException;
import com.pitop.core.exceptions.ProjectLogException;
import com.pitop.project.api.ProjectLogFeignApi;
import com.pitop.project.entity.ProjectLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 项目变更日志
 *
 * @author berton
 */
@Service("projectLogSVImpl")
@Slf4j
public class ProjectLogSVImpl {

    @Autowired
    private ProjectLogFeignApi projectLogFeignApi;

    /**
     * 加载一个对象ProjectLog
     *
     * @param id
     * @return ProjectLog
     */
    public ProjectLog load(Long id) {
        if (id == null) {
            throw new ProjectLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return projectLogFeignApi.load(id);
    }

    /**
     * 加载一个对象ProjectLog 通过id,(将查询关联数据)
     *
     * @param id
     * @return ProjectLog
     */
    public ProjectLog loadById(Long id) {
        if (id == null) {
            throw new ProjectLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return projectLogFeignApi.loadById(id);
    }


    /**
     * 删除对象ProjectLog
     *
     * @param id
     */

    public void delete(Long id) {
        if (id == null) {
            throw new ProjectLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        projectLogFeignApi.delete(id);
    }

    /**
     * 查询ProjectLog分页
     *
     * @param projectLog 对象
     * @param curPage    当前页
     * @param pageSize   分页条数
     * @return List<ProjectLog>
     */
    public List<ProjectLog> list(ProjectLog projectLog, int curPage, int pageSize) {
        return projectLogFeignApi.list(projectLog, curPage, pageSize);
    }

    /**
     * 查询ProjectLog分页
     *
     * @param id
     * @param curPage  当前页
     * @param pageSize 分页条数
     * @return List<ProjectLog>
     */
    public List<ProjectLog> list(Long id, int curPage, int pageSize) {
        if (curPage < 0) {
            curPage = 1;
        }

        if (pageSize < 0) {
            pageSize = Page.limit;
        }

        ProjectLog projectLog = new ProjectLog();
        projectLog.setId(id);

        return projectLogFeignApi.list(projectLog, curPage, pageSize);
    }

    public int count(Long id) {
        return projectLogFeignApi.count(id);
    }

    public int count(ProjectLog projectLog) {
        return projectLogFeignApi.count(projectLog);
    }

    /**
     * 保存
     *
     * @param projectLog 实体
     * @throws BaseException
     */
    public void save(ProjectLog projectLog) {
        if (projectLog == null) {
            throw new ProjectLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        projectLogFeignApi.build(projectLog);
    }

    /**
     * 更新
     *
     * @param projectLog 实体
     * @throws BaseException
     */
    public void modify(ProjectLog projectLog) {
        if (projectLog == null) {
            throw new ProjectLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        projectLogFeignApi.modify(projectLog);
    }
}
